using BepuPhysics;
using BepuPhysics.Collidables;
using BepuUtilities;
using BepuUtilities.Collections;
using DemoContentLoader;
using DemoRenderer;
using BepuUtilities;
using static Demos.Demos.CollisionTrackingDemo;

using SoftFloat;

namespace Demos.Demos
{
    internal class SimpleDemo : Demo
    {
        QuickList<ContactResponseParticle> particles;

        CollisionTracker collisionTracker;

        public override void Initialize(ContentArchive content, Camera camera)
        {
            camera.Position = new Vector3(0, 8, -20);
            camera.Yaw = MathHelper.Pi;

            particles = new QuickList<ContactResponseParticle>(8, BufferPool);

            collisionTracker = new CollisionTracker(BufferPool);
            Simulation = Simulation.Create(BufferPool, new CollisionTrackingCallbacks(collisionTracker), new DemoPoseIntegratorCallbacks(new Vector3(0, -10, 0)), new SolveDescription(8, 1));

            var listenedBody1 = Simulation.Bodies.Add(BodyDescription.CreateConvexDynamic(new Vector3(0, 5, 0), 1, Simulation.Shapes, new Box(1, 2, 3)));
            collisionTracker.Track(Simulation.Bodies[listenedBody1].CollidableReference);

            var listenedBody2 = Simulation.Bodies.Add(BodyDescription.CreateConvexDynamic(new Vector3((sfloat)0.5f, 10, 0), 1, Simulation.Shapes, new Capsule((sfloat)0.25f, (sfloat)0.7f)));
            collisionTracker.Track(Simulation.Bodies[listenedBody2].CollidableReference);

            Simulation.Statics.Add(new StaticDescription(new Vector3(0, -(sfloat)0.5f, 0), Simulation.Shapes.Add(new Box(30, 1, 30))));
            //Simulation.Statics.Add(new StaticDescription(new Vector3(0, 3, 15), Simulation.Shapes.Add(new Box(30, 5, 1))));
        }
    }
}
